// 用户相关类型
export interface User {
  id: number; // 统一使用数字类型，避免类型冲突
  username: string;
  email?: string | null; // 游客可能没有邮箱，允许null值
  realName?: string;
  avatar?: string;
  phone?: string;
  status: 'ACTIVE' | 'INACTIVE' | 'BANNED';
  lastLoginAt?: string;
  createdAt: string;
  updatedAt?: string;
  badges?: UserBadge[];
  notificationSettings?: UserNotificationSettings;
  isGuest?: boolean; // 是否为游客用户
}

export interface LoginRequest {
  username: string;
  password: string;
}

export interface RegisterRequest {
  username: string;
  password: string;
  realName?: string;
  email?: string;
  phone?: string;
}

// 游客登录响应类型
export interface GuestLoginResponse {
  user: User;
  token: string;
  refreshToken: string | null;
}

// 艺人相关类型
export interface Artist {
  id: number;
  name: string;
  description?: string;
  avatar?: string;
  bannerImage?: string;
  country?: string;
  status: 'ACTIVE' | 'INACTIVE';
  createdAt: string;
  updatedAt?: string;
  works?: Work[];
  performances?: Performance[];
  votes?: number;
  worksCount?: number;
  performancesCount?: number;
  followers?: number;
  hasVoted?: boolean;
  voteCount?: number;
}

export interface CreateArtistRequest {
  name: string;
  description?: string;
  genre?: string;
  country?: string;
  avatar?: string;
  bannerImage?: string;
  status?: 'ACTIVE' | 'INACTIVE';
}

export interface UpdateArtistRequest {
  name?: string;
  description?: string;
  genre?: string;
  country?: string;
  avatar?: string;
  bannerImage?: string;
  status?: 'ACTIVE' | 'INACTIVE';
}

export interface ArtistWork {
  id: number;
  artistId: number;
  title: string;
  duration?: string;
  description?: string;
  releaseDate?: string;
  isRepresentative: boolean;
  createdAt: string;
}

// 作品相关类型
export interface Work {
  id: number;
  artistId: number;
  title: string;
  description?: string;
  coverUrl?: string;
  releaseDate?: string;
  duration?: string;
  isRepresentative: boolean;
  createdAt: string;
  updatedAt: string;
  artist?: Artist;
}

export interface CreateWorkRequest {
  artistId: number;
  title: string;
  description?: string;
  coverUrl?: string;
  releaseDate?: string;
  duration?: string;
  isRepresentative?: boolean;
}

export interface UpdateWorkRequest {
  title?: string;
  description?: string;
  coverUrl?: string;
  releaseDate?: string;
  duration?: string;
  isRepresentative?: boolean;
}

// 演出相关类型
export interface Performance {
  id: number;
  artistId: number;
  title: string;
  description?: string;
  venue: string;
  floor?: string;
  startTime: string;
  endTime: string;
  status: 'SCHEDULED' | 'ONGOING' | 'COMPLETED' | 'CANCELLED';
  maxCapacity?: number;
  currentAttendance?: number;
  createdAt: string;
  updatedAt: string;
  artist?: Artist;
  countdown?: string;
}

// 投票相关类型
export interface Vote {
  id: number;
  userId: number;
  artistId: number;
  activityId: number;
  voteCount: number;
  createdAt: string;
  artist?: Artist;
  activity?: Activity;
}

export interface VoteLeaderboard {
  artistId: number;
  artistName: string;
  artistAvatar: string;
  voteCount: number;
  uniqueVoters?: number;
  hasVoted?: boolean;
  rank?: number;
  sortOrder?: number;
}

// 活动相关类型
export interface Activity {
  id: number;
  name: string;
  description?: string;
  startTime: string;
  endTime: string;
  status: 'ACTIVE' | 'INACTIVE' | 'COMPLETED' | 'CANCELLED';
  bannerImage?: string;
  rules?: string;
  maxVotesPerUser: number;
  createdAt: string;
  updatedAt: string;
  activityArtists?: ActivityArtist[];
  _count?: {
    activityArtists: number;
    votes: number;
  };
}

export interface ActivityArtist {
  id: number;
  activityId: number;
  artistId: number;
  sortOrder: number;
  createdAt: string;
  artist: Artist;
}

export interface ActivityVoteStatistics {
  activity: Activity;
  artistStats: ActivityArtistStats[];
}

export interface ActivityArtistStats {
  artist: Artist;
  totalVotes: number;
  uniqueVoters: number;
  sortOrder: number;
}

// 徽章相关类型
export interface Badge {
  id: number;
  name: string;
  description?: string;
  icon?: string;
  type?: string;
  conditionType?: string;
  conditionValue?: number;
  createdAt: string;
}

export interface UserBadge {
  id: number;
  userId: number;
  badgeId: number;
  earnedAt: string;
  badge?: Badge;
}

// 场地设施相关类型
export interface Facility {
  id: number;
  name: string;
  type: string;
  floor?: string;
  locationX?: number;
  locationY?: number;
  description?: string;
  status: 'OPEN' | 'CLOSED' | 'MAINTENANCE';
  createdAt: string;
  updatedAt: string;
}

// 冷知识相关类型
export interface Trivia {
  id: number;
  title: string;
  content: string;
  category?: string;
  artistId?: number;
  isActive: boolean;
  createdAt: string;
  artist?: Artist;
}

// AI助手相关类型
export interface AssistantConversation {
  id: number;
  userId: number;
  sessionId: string;
  createdAt: string;
  updatedAt: string;
  messages?: AssistantMessage[];
}

export interface AssistantMessage {
  id: number;
  conversationId: number;
  messageType: 'USER' | 'ASSISTANT';
  content: string;
  messageFormat: 'TEXT' | 'VOICE' | 'IMAGE';
  createdAt: string;
}

// 通知相关类型
export interface Notification {
  id: number;
  userId: number;
  title: string;
  content: string;
  type: 'PERFORMANCE' | 'VOTE' | 'SYSTEM' | 'PROMOTION';
  isRead: boolean;
  relatedId?: number;
  relatedType?: string;
  createdAt: string;
}

export interface UserNotificationSettings {
  id: number;
  userId: number;
  pushEnabled: boolean;
  emailEnabled: boolean;
  performanceReminder: boolean;
  voteReminder: boolean;
  createdAt: string;
  updatedAt: string;
}

// 用户位置相关类型
export interface UserLocation {
  id: number;
  userId: number;
  latitude: number;
  longitude: number;
  floor?: string;
  accuracy?: number;
  createdAt: string;
}

// 导航相关类型
export interface NavigationRoute {
  from: Facility;
  to: Facility;
  distance: number;
  duration: number;
  path: Array<{
    latitude: number;
    longitude: number;
  }>;
}

// 分页相关类型
export interface Pagination {
  page: number;
  limit: number;
  total: number;
  totalPages: number;
  hasNext: boolean;
  hasPrev: boolean;
}

export interface ApiResponse<T = any> {
  success: boolean;
  code: number;
  message: string;
  data: T;
  timestamp: string;
}

export interface PaginatedResponse<T> {
  items: T[];
  pagination: Pagination;
}

// 系统统计相关类型
export interface SystemStats {
  users: {
    total: number;
    active: number;
    banned: number;
  };
  artists: {
    total: number;
    active: number;
  };
  performances: {
    total: number;
    scheduled: number;
    ongoing: number;
    completed: number;
  };
  votes: {
    total: number;
    today: number;
  };
  loginTrend?: {
    daily: Array<{
      date: string;
      count: number;
    }>;
    monthly: Array<{
      month: string;
      count: number;
    }>;
    hourly: Array<{
      hour: string;
      count: number;
    }>;
  };
  userActivity?: {
    daily: Array<{
      date: string;
      count: number;
    }>;
    monthly: Array<{
      month: string;
      count: number;
    }>;
    hourly: Array<{
      hour: string;
      count: number;
    }>;
  };
  topUsers: Array<{
    id: number;
    username: string;
    realName?: string;
    operationCount: number;
  }>;
  topActions: Array<{
    action: string;
    count: number;
  }>;
}

// 权限相关类型
export interface Permission {
  id: number;
  name: string;
  code: string;
  description?: string;
  module: string;
  action: string;
  createdAt: string;
  updatedAt: string;
}

// 角色相关类型
export interface Role {
  id: number;
  name: string;
  description?: string;
  permissions?: any;
  status: 'ACTIVE' | 'INACTIVE';
  createdAt: string;
  updatedAt: string;
}

// 操作日志相关类型
export interface OperationLog {
  id: number;
  userId?: number;
  action: string;
  resource: string;
  resourceId?: string;
  details?: any;
  ipAddress?: string;
  userAgent?: string;
  createdAt: string;
  user?: User;
}

// 系统配置相关类型
export interface SystemConfig {
  id: number;
  key: string;
  value: string;
  description?: string;
  type: 'STRING' | 'NUMBER' | 'BOOLEAN' | 'JSON';
  createdAt: string;
  updatedAt: string;
}

// 文件上传相关类型
export interface UploadResponse {
  url: string;
  filename: string;
  size: number;
  type: string;
}

// 聊天消息类型
export interface ChatMessage {
  id: string;
  type: 'user' | 'assistant';
  content: string;
  timestamp: string;
  format?: 'text' | 'voice' | 'image';
}

// 快捷操作类型
export interface QuickAction {
  id: string;
  title: string;
  icon: string;
  action: string;
  description?: string;
}

// 地图相关类型
export interface MapLocation {
  id: string;
  name: string;
  type: string;
  latitude: number;
  longitude: number;
  floor?: string;
  icon?: string;
}

// 搜索相关类型
export interface SearchResult {
  type: 'artist' | 'performance' | 'facility' | 'trivia';
  id: number;
  title: string;
  description?: string;
  icon?: string;
  url: string;
} 